﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LostLib.Windows.Forms
{
	[DesignerCategory("Dialogs"), Description("Allows user to select keyboard shortcut")]
	public partial class KeySelectDialog: CommonDialog
	{
		public KeySelectDialog( )
		{
		}

		[Browsable(false), Description("Selected key")]
		public Keys Key
		{
			get;
			set;
		}

		public override void Reset( )
		{
			
		}

		protected override bool RunDialog(IntPtr hwndOwner)
		{
			bool result;
			using (var form = new KeySelectForm( ))
			{
				form.Key = Key;
				var owner = new NativeWindow( );
				owner.AssignHandle(hwndOwner);
				result = form.ShowDialog(owner) == DialogResult.OK;
				Key = form.Key;
			}
			return result;
		}
	}
}
